package org.xxforest.game.notsing;

import org.xxforest.game.core.XX;
import org.xxforest.game.core.XXDirector;
import org.xxforest.game.notsing.screen.GameScreenManager;

import com.badlogic.gdx.ApplicationListener;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.GL10;

public class GameApplication implements ApplicationListener{

	private static GameApplication applicationListener ;
	/**	SCREEN上下文*/
	private XXDirector director ;
	
	@Override
	public void create() {
		director = XXDirector.getInstance() ;
		XX.init() ;
		
		director.replaceScreen(GameScreenManager.getInstance().getTestScreen());
	}

	@Override
	public void dispose() {
		director.hide() ;
		director.disposeScreen();
	}
	
	public void hide(){
		director.hide();
	}

	@Override
	public void pause() {
		director.pause();
	}

	@Override
	public void render() {
		float deltaTime = Gdx.graphics.getDeltaTime();
		Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
		director.render(deltaTime);
	}

	@Override
	public void resize(int width, int height) {
	}

	@Override
	public void resume() {
		director.resume();
	}
	
	public static GameApplication getInstance() {
		if(applicationListener == null){
			applicationListener = new GameApplication() ;
		}
		return applicationListener;
	}

}
